package com.ark.frigate.dingtalk.utils;

import java.net.InetAddress;
import java.net.UnknownHostException;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author ZengWeiLong
 * @Description Copy Right Beyonca
 * @Date 2022/7/14 11:20
 * @Version 1.0
 */
@Slf4j
public class EnvironmentUtil {

    public static String getHostName() {
        String hostInfo;
        try {
            hostInfo = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException ignored) {
            log.warn("Get host fail", ignored);
            hostInfo = "unknown-host";
        }
        return hostInfo;
    }

    public static String getHostIp() {
        String ipInfo;
        try {
            ipInfo = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException ignored) {
            log.warn("Get ip fail", ignored);
            ipInfo = "unknown-ip";
        }
        return ipInfo;
    }
}
